package com.stone.customview;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(new MyView(this));

    }


    class MyView extends View {


        private Paint mPaint;
        public MyView(Context context) {
            super(context);

            Shader mShader = new LinearGradient(0, 0, 40, 60, new int[] {
                    Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW }, null,
                    Shader.TileMode.REPEAT);
            mPaint = new Paint();
            mPaint.setColor(Color.RED);
            mPaint.setStrokeWidth(3);
            mPaint.setAntiAlias(true);
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setShader(mShader);


        }

        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            //canvas.drawCircle(100, 100, 50, mPaint);

            RectF rect = new RectF(0, 0, 500, 500);
            canvas.drawArc(rect, -90, 360, false, mPaint);
        }
    }

}
